public class SingletonLazy {
    private volatile static SingletonLazy instance = null; //3.这里加 volatile 有什么用
    private static Object locker = new Object();
    public static SingletonLazy getInstance() {
        if (instance == null) { //2.这里为啥要判断 instance 是否为空
            synchronized (locker) { //1.这里为啥要加锁
                if (instance == null)
                    instance = new SingletonLazy();
            }
        }
        return instance;
    }

    private SingletonLazy() {}

    public static void main(String[] args) {
        
    }
}
